package com.zhome.gateway.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时刷新路由信息
 * @author cuiyh9
 * @date 2020/5/9
 */
@Slf4j
@Component
public class RefreshRouteTask {

    @Autowired
    private ZuulHandlerMapping zuulHandlerMapping;

    @Scheduled(fixedRateString = "${refresh.routes.interval}")
    public void refresh() {
        zuulHandlerMapping.setDirty(true);
    }
}
